const THREE = require("three")
let OBJECTS = {
  cam_target: undefined,
  clock: new THREE.Clock(),
  delta: 0,
  audioListener: new THREE.AudioListener(),
  interval: 0.001,
  scenes: {},
  materials: {},
  tooltips: {},
  textures: {},
  actors: {},
  geos: {},
  meshes: {},
  models: {},
  lights: {},
  animation: {
    mixer: undefined,
    clips: [],
  },
  postprocessing: {
    composer: undefined,
  },
  groups: {},
  fonts: {},
  rules: {},
  helpers: {},
  input: {
    velocity: {
      last: 0,
      current: 0,
    },
    permitted: false,
  },
  ray: {
    caster: new THREE.Raycaster(),
    intersects: [],
    mouse: new THREE.Vector2(),
    ready: true,
  },
  levels: {},
  selector: {
    enabled: true,
    current: undefined,
  },
  cameras: [],
  lockInput: false,
  imgseq: {},
  curvepath: undefined,
  curveobject_drive: undefined,
  curvepath_points: [new THREE.Vector3(0, 0, -10)],
  curvepath_velocity: [0.03],
  curvepath_follow: undefined,

  // preview path
  curvepath_preview_points: [new THREE.Vector3(0, 0, -10)],
  curvepath_preview_velocity: [0.03],
  curvepath_preview_follow: undefined,


  pointerCamera: undefined,
  pointerCamera_target: undefined,
  currentCamera: undefined,
  containerCamera: undefined,
  car_follow: new THREE.Object3D(),
  pages: ["preloader", "title", "game"],
  // curvePaths:[],
  curvepath_extra: {},
  // flowobject: undefined,
}

let PLAYERS = {
  me: {
    // position:
    // look: {
    //   face : 0,
    //   skin : 0,
    // },
  },
}

let FLAGS = {
  hold: false,
  locale: "",
  percentLoaded: {
    current: 0,
    ready: 100,
  },
  lock: false,
  hotspotHover: false,
  modelFound: false,
  isReady: false,
  isLoaded: false,
  isEnabled: false,
  isDriveReady: false,
  appleSelected: false,
  camera: false,
  cameraOrientationUpdated: false,
  selector: {
    enabled: true,
  },
  page: {
    current: "selector",
    last: undefined,
  },
  input: {
    shake: {
      enabled: true,
    },
  },
  orientation: undefined,
  room: "loading",
  prevLevel: undefined,
  lastRayTarget: undefined,
  // TODO : implement separate steps for both experiences
  curvepath_preview_step: 5,
  curvepath_drive_step: 10,

  // curvepath_step: 10,
  curvepath_step: 10,
  curvepath_readydrive: 10, // for testing
  // curvepath_readydrive: 100,

  driveReady: false,
  driveCurrentSpeed: 0,
  driveAccelerationRate: 0.0005,
  driveDeccelerationRate: 0.0002,
  driveMaxSpeed: 0.0005,
  driveMinSpeed: 0.0001,
  driveSteerMax: 4,
  // driveSteerMultiplier: 5,
  driveFlow : undefined,  // deprecated, flow only works for Meshes
}

let LOCALE = {
  data: {},
}

let LEVELS = {}

let ID = {}

let UTILS = {
  sw: window.innerWidth,
  sh: window.innerHeight,
}

export { OBJECTS, FLAGS, UTILS, ID, LOCALE, LEVELS, PLAYERS }
